#ifndef SPRITE_H
#define SPRITE_H

#include "../collisions/collidable.h"
#include "../shapes.h"
#include "../scenegraph.h"

using namespace collisions;

namespace sprites
{
	class Sprite : public Collidable
	{
	private:
		//3 dummy nodes for rotations
		ParentNode* horzNode;
		ParentNode* vertNode;
		ParentNode* forwardNode;

	protected:

		//main scenegraph node, parent to all others
		ParentNode parent;

		//basic collision stuff
		collisions::BindingSphere bound;
		vector<collisions::BindingSphere> bindingShapes;

		//needed to see if the object has been destroyed in game
		bool dying;
		bool dead;

		//used for animation purposes
		int currentFrame;

		//initial position
		Vector3D pos;
		MatterType type;

		//used for rotation
		float horzAngle;
		float vertAngle;

		//used to attach the object's body (the shapes)
		ParentNode* root;

		//allows the object's shape to be changed.
		float scale;

		//helper function
	    void setVector(float * vector, float x, float y, float z);

	public: 
		//Constructor
		Sprite(Vector3D _pos, MatterType _type, float boundRadius, float scale);
		
		//used to get location of object in game
		Vector3D getPosition();
		void setPosition(Vector3D _position);

		//Take the whole concept of OO and shoot it in the foot
		float forwardAngle;

		//used to move sprites easily
		void operator+=(Vector3D _move);
		
		//to make sure we create the object's body
		virtual void build() = 0;

		//implementation of Collidable
		virtual MatterType getMatterType();

		//rotation functions
		void rotateHorizontal(float _degrees);
		void rotateVertical(float _degrees);
		void rotateForward(float _degrees); //rotation on the x-axis
		void resetRotation();

		//called by the game to display the object to screen
		virtual void draw();

		//used for gameplay
		bool isDead();
		void revive();
	};
}
#endif